package
{
	public class Utils
	{
		/* Parse a string of whitespace-delimited tokens into an array. */
		public static function Tokenize(str:String):Array {
			return str.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/);
		}
		
		public static function MDArray(cols:uint, rows:uint):Array {			
			//np.debug.print("new matrix: "+rows+" rows by "+cols+" cols");
			var a:Array = new Array();
			for (var i:uint = 0; i < rows; i++) {
				var b:Array = new Array();
				for (var j:uint = 0; j < cols; j++) b.push(new int(0));
				a.push(b);
			}
			return a;
		}
		
		public static function DumpMatrix(a:Array):void {
			np.debug.print(" ");
			for each (var row:Array in a) {
				var s:String = "";
				for each (var item:int in row) {
					var n:String = item.toString();
					var sp:String = "";
					for (var i:int = 0; i < (4 - n.length); i++) sp = sp + " ";
					s = s + n + sp;
				}
				np.debug.print(s);
			}
			np.debug.print(" ");
		}
		
		/*
		public static function MakeHash(keys:Array, vals:Array):Array {
			if (keys.length != vals.length) throw new Error("Cannot form hash: lists differ in length.");
			
			
		}
		*/
	}
}